@echo off

rem ---------------------------------------------------------------------------
rem Startup script for XContainer Server (with default parameters)
rem
rem Environment Variable Prequisites
rem
rem   XCONTAINER_HOME   Must point at your XContainer directory 
rem
rem   JAVA_HOME         Must point at your Java Development Kit installation.
rem
rem   JAVA_OPTS         (Optional) Java runtime options 
rem ---------------------------------------------------------------------------

if "%OS%"=="Windows_NT" @setlocal
if "%OS%"=="WINNT" @setlocal

rem %~dp0 is expanded pathname of the current script under NT
set DEFAULT_XCONTAINER_HOME=%~dp0

if "%XCONTAINER_HOME%"=="" set XCONTAINER_HOME=%DEFAULT_XCONTAINER_HOME%
set DEFAULT_AXIS2_HOME=

rem find XCONTAINER_HOME if it does not exist due to either an invalid value passed
rem by the user or the %0 problem on Windows 9x

if exist "%XCONTAINER_HOME%\conf\xcontainer.xml" goto checkJava

:noXContainerHome
echo XCONTAINER_HOME environment variable is set incorrectly or XContainer could not be located. 
echo Please set the XCONTAINER_HOME variable appropriately
goto end

:checkJava
set _JAVACMD=%JAVACMD%

if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe

goto runXContainer

:noJavaHome
if "%_JAVACMD%" == "" set _JAVACMD=java.exe
echo JAVA_HOME environment variable is set incorrectly or Java runtime could not be located.
echo Please set the JAVA_HOME variable appropriately
goto end

:runXContainer
rem set the classes by looping through the libs
setlocal EnableDelayedExpansion
set XCONTAINER_CLASS_PATH=%XCONTAINER_HOME%;%JAVA_HOME%\lib\tools.jar;
FOR %%c in ("%XCONTAINER_HOME%\lib\*.jar") DO set XCONTAINER_CLASS_PATH=!XCONTAINER_CLASS_PATH!;%%c

echo Using JAVA_HOME    %JAVA_HOME%
echo Using XCONTAINER_HOME   %XCONTAINER_HOME%

cd %XCONTAINER_HOME%
"%_JAVACMD%" %JAVA_OPTS% -cp "!XCONTAINER_CLASS_PATH!" org.act.xservices.rt.xcontainer.container.XContainerMain
goto end

:end
set _JAVACMD=

if "%OS%"=="Windows_NT" @endlocal
if "%OS%"=="WINNT" @endlocal

:mainEnd
